﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.Services;
using System.Data;

namespace HocSinhService
{
    /// <summary>
    /// Summary description for Service1
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    public class Service1 : System.Web.Services.WebService
    {

        [WebMethod]
        public int ThemHocSinh(string MSHS, string HoTen, DateTime NgaySinh, float DTB)
        {
            try
            {
                string sql = "insert into HOCSINH(MSHS,HoTen,NgaySinh,DTB) values('" + MSHS + "',N'" + HoTen + "','" + NgaySinh + "'," + DTB + ")";
                HocSinhDAO.ExecuteNoneQuery(sql);
                return 1;
            }
            catch
            {
                return 0;
            }
        }
        [WebMethod]
        public DataSet LayDanhSach()
        {
            DataSet db = new DataSet();
            string sql = "select * from HOCSINH";
            db = HocSinhDAO.ExecuteQuery2(sql);
            return db;

        }
        [WebMethod]
        public int CapNhat(DataTable dt)
        {
            string sql = "select * from HOCSINH";
            try
            {
                HocSinhDAO.Update(sql, dt);
                return 1;
            }
            catch
            {
                return 0;
            }
        }
    }
}